import Vue from 'vue'
import VueRouter from 'vue-router'

//解决重复点击路由报错
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter)

const Home = ()=>import('@/views/Home')
const Special = ()=>import('@/views/Special')
const Category = ()=>import('@/views/Category')
const Cart = ()=>import('@/views/Cart')
const Profile = ()=>import('@/views/Profile')

const routes = [
  {
    path:'',
    redirect:'/home'
  },
  {
    path:'/home',
    component:Home
  },
  {
    path:'/special',
    component:Special
  },
  {
    path:'/category',
    component:Category
  },{
    path:'/cart',
    component:Cart
  },{
    path:'/profile',
    component:Profile
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
